package org.dreamwork.drawing.framework.impl;

import org.dreamwork.drawing.framework.IVertex;

import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;

/**
 * Created by IntelliJ IDEA.
 * User: seth.yang
 * Date: 2010-8-3
 * Time: 15:39:11
 */
public class DefaultVertex implements IVertex {
    protected Point2D location;
    protected Dimension2D size;
    protected Object userObject;

    public Point2D getLocation () {
        return location;
    }

    public void setLocation (Point2D location) {
        this.location = location;
    }

    public Dimension2D getSize () {
        return size;
    }

    public void setSize (Dimension2D size) {
        this.size = size;
    }

    public Object getUserObject () {
        return userObject;
    }

    public void moveTo (Point2D target) {
        location.setLocation (target);
    }

    public void moveBy (Point2D offset) {
        location.setLocation (location.getX () + offset.getX (), location.getY () + offset.getY ());
    }

    public void resizeTo (Dimension2D target) {
        size.setSize (target);
    }

    public void resizeBy (Dimension2D offset) {
        size.setSize (size.getWidth () + offset.getWidth (), size.getHeight () + offset.getHeight ());
    }

    public void setUserObject (Object userObject) {
        this.userObject = userObject;
    }
}